package mortal.game.net.rmi
{
	import Engine.RMI.*;
	import Message.Game.*;
	import mortal.common.net.*;
	import mortal.game.manager.*;
	import mortal.game.net.*;
	
	public class GameRMI extends RMIBase
	{
		public var loginGameProxy:ILoginGamePrxHelper;
		
		/*
		public var iOprationPrx:IOperationPrxHelper;
		public var iBagPrxHelper:IBagPrxHelper;
		public var iItemPrxHelper:IItemPrxHelper;
		public var iRolePrxHelper:IRolePrxHelper;
		public var iMountsHelper:IMountPrxHelper;
		public var iTaskHelper:ITaskPrxHelper;
		public var iShopPrxHelper:IShopPrxHelper;
		public var iInteractivePrxHelper:IInteractivePrxHelper;
		public var iPlayerHelper:IPlayerPrxHelper;
		public var iFriendPrxHelper:IFriendPrxHelper;
		public var iMailPrxHelper:IMailPrxHelper;
		public var iTestPrxHelper:ITestPrxHelper;
		public var iWareHosueHelper:IBagPrxHelper;
		public var iPlayerPrxHelper:IPlayerPrxHelper;
		public var iBusinessPrxHelper:IBusinessPrxHelper;
		public var iPetPrxHelper:IPetPrxHelper;
		public var iGroupPrxHelper:IGroupPrxHelper;
		public var iPanicBuyPrxHelper:IPanicBuyPrxHelper;
		public var iCopyPrxHelper:ICopyPrxHelper;
		public var iOfflineExpPrxHelper:IOfflineExpPrxHelper;
		public var iToplistPrxHelper:IToplistPrxHelper;
		public var iGuildPrxHelper:IGuildPrxHelper;
		public var iStallPrxHelper:IStallPrxHelper;
		public var iTargetPrxHelper:IComprehensionTargetPrxHelper;
		public var iRunBusinessPrxHelper:IRunBusinessPrxHelper;
		public var iAcupointPrxHelper:IAcupointPrxHelper;
		*/
		private static var _instance:GameRMI;
		
		public function GameRMI()
		{
			this.loginGameProxy = new ILoginGamePrxHelper();
			/*
			this.iOprationPrx = new IOperationPrxHelper();			
			this.iBagPrxHelper = new IBagPrxHelper();
			this.iItemPrxHelper = new IItemPrxHelper();
			this.iRolePrxHelper = new IRolePrxHelper();
			this.iMountsHelper = new IMountPrxHelper();
			this.iTaskHelper = new ITaskPrxHelper();
			this.iShopPrxHelper = new IShopPrxHelper();
			this.iInteractivePrxHelper = new IInteractivePrxHelper();
			this.iPlayerHelper = new IPlayerPrxHelper();
			this.iFriendPrxHelper = new IFriendPrxHelper();
			this.iMailPrxHelper = new IMailPrxHelper();
			this.iTestPrxHelper = new ITestPrxHelper();
			this.iWareHosueHelper = new IBagPrxHelper();
			this.iPlayerPrxHelper = new IPlayerPrxHelper();
			this.iBusinessPrxHelper = new IBusinessPrxHelper();
			this.iPetPrxHelper = new IPetPrxHelper();
			this.iGroupPrxHelper = new IGroupPrxHelper();
			this.iPanicBuyPrxHelper = new IPanicBuyPrxHelper();
			this.iCopyPrxHelper = new ICopyPrxHelper();
			this.iOfflineExpPrxHelper = new IOfflineExpPrxHelper();
			this.iToplistPrxHelper = new IToplistPrxHelper();
			this.iGuildPrxHelper = new IGuildPrxHelper();
			this.iStallPrxHelper = new IStallPrxHelper();
			this.iTargetPrxHelper = new IComprehensionTargetPrxHelper();
			this.iRunBusinessPrxHelper = new IRunBusinessPrxHelper();
			this.iAcupointPrxHelper = new IAcupointPrxHelper();
			*/
			if (_instance != null)
			{
				throw new Error(" GameRMI 单例 ");
			}
			
			RMIDispatcher.getInstance().addEventListener(RMIEvent.RMI_ERROR, this.onRmiErrorHandler);
		}
		
		private function onRmiErrorHandler(event:RMIEvent) : void
		{
			MsgManager.systemError(event.error);	
		}
		
		override public function set rmiSession(session:RMISession) : void
		{
			session.session.messageHandler = new MessageHandler();
			session.session.communicator.sessionEvent = new RMISessionEvent();
			super.rmiSession = session;	
		}
		
		override protected function initProxy() : void
		{
			session.registerProxy(this.loginGameProxy);
			/*
			session.registerProxy(this.iOprationPrx);
			session.registerProxy(this.iBagPrxHelper);
			session.registerProxy(this.iRolePrxHelper);
			session.registerProxy(this.iTestPrxHelper);
			session.registerProxy(this.iItemPrxHelper);
			session.registerProxy(this.iTaskHelper);
			session.registerProxy(this.iMountsHelper);
			session.registerProxy(this.iShopPrxHelper);
			session.registerProxy(this.iWareHosueHelper);
			session.registerProxy(this.iInteractivePrxHelper);
			session.registerProxy(this.iMailPrxHelper);
			session.registerProxy(this.iFriendPrxHelper);
			session.registerProxy(this.iPlayerHelper);
			session.registerProxy(this.iBusinessPrxHelper);
			session.registerProxy(this.iPlayerPrxHelper);
			session.registerProxy(this.iPetPrxHelper);
			session.registerProxy(this.iGroupPrxHelper);
			session.registerProxy(this.iPanicBuyPrxHelper);
			session.registerProxy(this.iCopyPrxHelper);
			session.registerProxy(this.iOfflineExpPrxHelper);
			session.registerProxy(this.iToplistPrxHelper);
			session.registerProxy(this.iGuildPrxHelper);
			session.registerProxy(this.iStallPrxHelper);
			session.registerProxy(this.iTargetPrxHelper);
			session.registerProxy(this.iRunBusinessPrxHelper);
			session.registerProxy(this.iAcupointPrxHelper);
			*/
		}
		
		public static function get instance() : GameRMI
		{
			if (_instance == null)
			{
				_instance = new GameRMI;
			}
			return _instance;
		}
		
	}
}
